
function trim(str){
　　 return str.replace(/(^\s*)|(\s*$)/g, "");
}

function downFile(id){
	var param=new Object();
	param["id"]=id;
	submitCore(param,"doDownFile","doDownFile");
}
function doDownFile(data){
	var flag=data["flag"];
	if(flag==1){
		//var url=data["url"];
		//openwin(url);
		return;
	}else{
		var msg=getCommonMsg(flag);
		parent.atInfo(msg);
	}
}
//注册
function reg(){
	var username=$("#username").val();
	var password=$("#password").val();
	var password2=$("#password2").val();
	var realname=$("#realname").val();
	var xh=$("#xh").val();
	var sex=getRadioValue("sex");
	var credit=$("#credit").val();
	var zy=$("#zy").val();
	var pro=$("#pro").val();
	if(username==""){
		parent.atInfo("请输入用户名!");
	}else if(password==""||password.length<6){
		parent.atInfo("请输入密码，6位以上!");
	}else if(password2!=password){
		parent.atInfo("2次密码不一致!");
	}else if(realname==""){
		parent.atInfo("请输入姓名!");
	}else if(xh==""){
		parent.atInfo("请输入学号!");
	}else if(sex==""){
		parent.atInfo("请选择性别!");
	}else if(credit.length!=15&&credit.length!=18){
		parent.atInfo("请输入身份证,15或18位!");
	}else if(zy==""){
		parent.atInfo("请输入专业!");
	}else if(pro==""){
		parent.atInfo("请输入省份!");
	}else{
		var param=new Object();
		param["username"]=username;
		param["password"]=password;
		param["realname"]=realname;
		param["xh"]=xh;
		param["sex"]=sex;
		param["credit"]=credit;
		param["zy"]=zy;
		param["pro"]=pro;
		submitCore(param,"reg","doReg");
	}
}
function doReg(data){
	var flag=data["flag"];
	if(flag==1){
		parent.atInfo("注册成功,请登录!",function(){location.href="index.htm";});
		return;
	}else{
		var msg=getCommonMsg(flag);
		parent.atInfo(msg);
	}
}

//登录
function login(){
	var username=$("#username").val();
	var password=$("#password").val();
	var xz=getCheckboxValue("xz");
	if(username==""){
		parent.atInfo("请输入用户名!");
	}else if(password==""){
		parent.atInfo("请输入密码!");
	}else{
		var param=new Object();
		param["username"]=username;
		param["password"]=password;
		param["xz"]=xz;
		submitCore(param,"login","doLogin");
	}
}
function doLogin(data){
	var flag=data["flag"];
	if(flag==1){
		toUrl("user.htm");
		return;
	}else{
		var msg=data["msg"];
		parent.atInfo(msg);
	}
}

function saveHead(url){
	var param=new Object();
	param["url"]=url;
	submitCore(param,"doSaveHead","doCommonReloadOkReturn");
}

function saveForum(id){
	var msg=$("#msg").val();
	if(msg==""){
		parent.atInfo("请输入发表信息!");
	}else{
		atConfirm("确定要发表吗?",function(){
			var param=new Object();
			param["id"]=id;
			param["msg"]=msg;
			submitCore(param,"doSaveForum","doCommonReturn");
		});
	}
}

function saveQuestion(id){
	var msg=$("#msg").val();
	if(msg==""){
		parent.atInfo("请输入提问信息!");
	}else{
		atConfirm("确定要提问吗?",function(){
			var param=new Object();
			param["id"]=id;
			param["msg"]=msg;
			submitCore(param,"doSaveQuestion","doCommonReturn1");
		});
	}
}

function saveAnswer(id){
	var msg=$("#msg").val();
	if(msg==""){
		parent.atInfo("请输入回答信息!");
	}else{
		atConfirm("确定要回答吗?",function(){
			var param=new Object();
			param["id"]=id;
			param["msg"]=msg;
			submitCore(param,"doSaveAnswer","doCommonReturn1");
		});
	}
}
function closeBookView(id){
	parent.atConfirm("确定要关闭提醒吗?",function(){
		var param=new Object();
		param["id"]=id;
		submitCore(param,"doCloseBookView","doCommonReturn");
	});
}

function countTime(bid,did){
	var param=new Object();
	param["bid"]=bid;
	param["did"]=did;
	submitCore(param,"doCountTime","doCountTime");
}
function doCountTime(data){
}

function addBookFile(bid){
	var type=$("#type").val();
	var name=$("#name").val();
	var url=$("#url").val();
	if(name==""){
		parent.atInfo("请输入资料名称");
	}else if(url==""){
		parent.atInfo("请输入资料地址");
	}else{
		var param=new Object();
		param["bid"]=bid;
		param["type"]=type;
		param["name"]=name;
		param["url"]=url;
		submitCore(param,"doAddBookFile","doAddBookFile");
	}
}
function doAddBookFile(data){
	var flag=data["flag"];
	if(flag==1){
		var id=data["id"];
		atInfo("上传成功",function(){parent.location.href="book.htm?id="+id+"&lay=3";});
		return;
	}else{
		var msg=getCommonMsg(flag);
		parent.atInfo(msg);
	}
}
function addNotice(type,bid){
	var title=$("#title").val();
	var msg=$("#msg").val();
	if(title==""){
		parent.atInfo("请输入标题");
	}else if(msg==""){
		parent.atInfo("请输入内容");
	}else{
		parent.atConfirm("确定要发布吗?",function(){
			var param=new Object();
			param["type"]=type;
			param["title"]=title;
			param["msg"]=msg;
			param["bid"]=bid;
			submitCore(param,"doAddNotice","doAddNotice");
		});
	}
}
function doAddNotice(data){
	var flag=data["flag"];
	if(flag==1){
		atInfo("发布成功",function(){parent.location.reload();});
		return;
	}else{
		var msg=getCommonMsg(flag);
		parent.atInfo(msg);
	}
}